package com.ruoyi.yqhs.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yqhs.domain.YqhsSjdc;
import com.ruoyi.yqhs.service.IYqhsSjdcService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 数据断传Controller
 * 
 * @author ruoyi
 * @date 2025-08-31
 */
@RestController
@RequestMapping("/yqhs/sjdc")
public class YqhsSjdcController extends BaseController
{
    @Autowired
    private IYqhsSjdcService yqhsSjdcService;

    /**
     * 查询数据断传列表
     */
    @PreAuthorize("@ss.hasPermi('yqhs:sjdc:list')")
    @GetMapping("/list")
    public TableDataInfo list(YqhsSjdc yqhsSjdc)
    {
        startPage();
        List<YqhsSjdc> list = yqhsSjdcService.selectYqhsSjdcList(yqhsSjdc);
        return getDataTable(list);
    }

    /**
     * 导出数据断传列表
     */
    @PreAuthorize("@ss.hasPermi('yqhs:sjdc:export')")
    @Log(title = "数据断传", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YqhsSjdc yqhsSjdc)
    {
        List<YqhsSjdc> list = yqhsSjdcService.selectYqhsSjdcList(yqhsSjdc);
        ExcelUtil<YqhsSjdc> util = new ExcelUtil<YqhsSjdc>(YqhsSjdc.class);
        util.exportExcel(response, list, "数据断传数据");
    }

    /**
     * 获取数据断传详细信息
     */
    @PreAuthorize("@ss.hasPermi('yqhs:sjdc:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(yqhsSjdcService.selectYqhsSjdcById(id));
    }

    /**
     * 新增数据断传
     */
    @PreAuthorize("@ss.hasPermi('yqhs:sjdc:add')")
    @Log(title = "数据断传", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YqhsSjdc yqhsSjdc)
    {
        return toAjax(yqhsSjdcService.insertYqhsSjdc(yqhsSjdc));
    }

    /**
     * 修改数据断传
     */
    @PreAuthorize("@ss.hasPermi('yqhs:sjdc:edit')")
    @Log(title = "数据断传", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YqhsSjdc yqhsSjdc)
    {
        return toAjax(yqhsSjdcService.updateYqhsSjdc(yqhsSjdc));
    }

    /**
     * 删除数据断传
     */
    @PreAuthorize("@ss.hasPermi('yqhs:sjdc:remove')")
    @Log(title = "数据断传", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(yqhsSjdcService.deleteYqhsSjdcByIds(ids));
    }
}
